<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Templateadmin extends Model
{
    protected $table = 'template_admin';
    protected $primaryKey = 'id';

    public static function templateAdminLists($users_id)
    {
        return self::where("users_id",$users_id)->where("disable",1)->get();
    }

    public static function userTemplateAdmin($users_id)
    {
        return self::select("id","manage_name","manage_name","manage_email","manage_mobile")->where("users_id",$users_id)->where("disable",1)->get();
    }

    public static function templateAdminCount($users_id)
    {
        return self::where("users_id",$users_id)->where("disable",1)->count("id");
    }

    public static function templateAdminByIdcard($users_id,$idcard)
    {
        return self::where("users_id",$users_id)->where("manage_idcard",$idcard)->where("disable",1)->first();
    }

    public static function templateAdminDisable($id,$disable)
    {
        return self::where("id",$id)->update(["disable"=>$disable]);
    }

    public static function templateAdminDetial($id)
    {
        return self::where("id",$id)->first();
    }

    public static function templateAdminUpdate($id,$manage_name,$manage_idcard,$manage_date_start,$manage_date_end,$manage_email,$manage_mobile,$manage_emergency_contact,$manage_photo_front,$manage_photo_back)
    {
        return self::where("id",$id)->update(["manage_name"=>$manage_name,"manage_idcard"=>$manage_idcard,"manage_date_start"=>$manage_date_start,"manage_date_end"=>$manage_date_end,"manage_email"=>$manage_email,"manage_mobile"=>$manage_mobile,"manage_emergency_contact"=>$manage_emergency_contact,"manage_photo_front"=>$manage_photo_front,"manage_photo_back"=>$manage_photo_back]);
    }

    public static function templateAdminInsert($users_id,$manage_name,$manage_idcard,$manage_date_start,$manage_date_end,$manage_email,$manage_mobile,$manage_emergency_contact,$manage_photo_front,$manage_photo_back)
    {
        return self::insert(["users_id"=>$users_id,"manage_name"=>$manage_name,"manage_idcard"=>$manage_idcard,"manage_date_start"=>$manage_date_start,"manage_date_end"=>$manage_date_end,"manage_email"=>$manage_email,"manage_mobile"=>$manage_mobile,"manage_emergency_contact"=>$manage_emergency_contact,"manage_photo_front"=>$manage_photo_front,"manage_photo_back"=>$manage_photo_back,"created_at"=>time()]);
    }
}
